
import math


def GMscore(a, b, c, d, q):
	'''
	公式3.6Sgm
	:param a:
	:param b:
	:param c:
	:param d:
	:param q:
	:return:
	'''
	A = a ** q
	B = b ** q
	C = c ** q
	D = d ** q
	score = (C + D - A - B) / 2 + (A + B + 2 * (A * B - C * D)) / (A + B + C + D)
	return score

def Newscore(a, b, c, d, q):
	score = ((a ** q + b ** q + ((a + b) / 2) ** q) / 3 - (c ** q + d ** q + ((c + d) / 2) ** q) / 3 + (
				a ** q + b ** q - c ** q - d ** q) / 2
	         - math.cos(((a ** q + b ** q) / 2) * 0.5 * (math.pi))
	         + math.cos(((c ** q + d ** q) / 2) * 0.5 * (math.pi))) / 3
	return score


if __name__ == "__main__":
	q = 1
	
	print("GM score ...........................")
	ROFN2 = [[([0.35, 0.5], [0.1, 0.1]), ([0.35, 0.5], [0.05, 0.15])],
	
	         [([0, 0.4], [0, 0.4]), ([0.2, 0.2], [0.2, 0.2])],
	         [([0.35, 0.45], [0.2, 0.3]), ([0.3, 0.5], [0.15, 0.35])]]
	
	# <[0.3, 0.5], [0.2, 0.4]>, <[0.35, 0.45], [0.25, 0.35]>
	# <[0.35, 0.45], [0.2, 0.3]>, <[0.3, 0.5], [0.15, 0.35]>
	from Data.IVq_ROF import getScoreequalRandomtwoq_ROFNs_1
	while True:
		a,b=getScoreequalRandomtwoq_ROFNs_1(1)
		x1=GMscore(a[0][0], a[0][1], a[1][0], a[1][1], 1)
		x2=GMscore(b[0][0], b[0][1], b[1][0], b[1][1], 1)
		x3=Newscore(a[0][0], a[0][1], a[1][0], a[1][1], 1)
		x4=Newscore(b[0][0], b[0][1], b[1][0], b[1][1], 1)
		if x1==x2 :
			print(a,'\n',b)

	# print(GMscore(0.11, 0.25, 0.29, 0.37,1)  )
	# print(GMscore(0.18, 0.28, 0.36, 0.54,1) )
	# print(Newscore(0.11, 0.25, 0.29, 0.37,1) )
	# print(Newscore(0.18, 0.28, 0.36, 0.54,1))
	
	# for i in range(len(ROFN2)):
	# 	ROFNs = ROFN2[i]
	# 	score0 = GMscore(ROFNs[0][0][0], ROFNs[0][0][1], ROFNs[0][1][0], ROFNs[0][1][1], q)
	# 	score1 = GMscore(ROFNs[1][0][0], ROFNs[1][0][1], ROFNs[1][1][0], ROFNs[1][1][1], q)
	# 	score2 = Newscore(ROFNs[0][0][0], ROFNs[0][0][1], ROFNs[0][1][0], ROFNs[0][1][1], q)
	# 	score3 = Newscore(ROFNs[1][0][0], ROFNs[1][0][1], ROFNs[1][1][0], ROFNs[1][1][1], q)
	# 	print(ROFNs)
	# 	print('测试函数:GMscore', round(score0, 4), round(score1, 4), '新得分函数:', round(score2, 4), round(score3, 4))